package com.sjf.day02.AnnoTest.demo;

import java.lang.reflect.Method;

/**
 * 测试注解的Controller
 *
 * @author <huangtang>
 * @since 2021/12/28 9:34
 **/
@ClassAnnotation(ClassName = "Controller 控制类")
public class TestController {

    public static void main(String[] args) {
        Class<TestController> clazz = TestController.class;
        ClassAnnotation classAnnotation = clazz.getAnnotation(ClassAnnotation.class);
        System.out.println("类的描述为:"+classAnnotation.ClassName());
        Method[] methods = clazz.getMethods();
        for (Method method : methods) {
            if(method.isAnnotationPresent(MethodAnnotation.class)){
                MethodAnnotation methodAnnotation = method.getAnnotation(MethodAnnotation.class);
                System.out.printf("方法名为 %s \t 对应的登录权限为 %d \n",methodAnnotation.MethodName(),
                        methodAnnotation.type());
            }
        }
    }

    @MethodAnnotation(MethodName = "有限制的访问",type = 0)
    public void t1(){

    }
    @MethodAnnotation(MethodName = "登录就能访问",type = 1)
    public void t2(){

    }

}
